//
// Created by wze-zero on 2024/9/16 016.
//
#include <iostream>

using namespace std;

int main() {
    int num, n, m, count = 0;
    cin >> num >> n;
    for (int i = 1; i < num + 1; ++i) {
        m = i;
        while (m != 0) {
            if (n == m % 10) {
                count++;
            }
            m /= 10;
        }
    }
    cout << count << endl;
    return 0;
}